home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Info 1994 March
/
Internet Info CD-ROM (Walnut Creek) (March 1994).iso
/
networking
/
mail
/
mh
/
contrib
/
multimedia
/
mhweather.shar
/
mhnsend
< prev
next >
Wrap
Text File
|
1993-03-15
|
2KB
|
107 lines
#!/usr/bin/perl
#
# mhnsend - run mhn non-interactively on the draft and then post the draft
#
# Author: Jerry Sweet <jns@fernwood.mpk.ca.us>
#
# $Id: mhnsend,v 1.3 1992/11/11 08:48:33 jsweet Exp $
#
# Subprograms
#
sub barf {
print STDERR "$prog: ", @_, "\n";
exit 1;
}
sub sh {
local($_) = @_;
local($st);
if ($verbose) {
print "\t$_\n";
}
return if $debug;
$st = system "$_";
if ($st >> 8) {
split;
&barf("$_[0] failed with status ", $st >> 8);
}
}
sub read_profile {
# Defines associative array %PROFILE_COMPONENT indexed by lower case
# component name. Continuation lines are tacked on. New
# occurrences of a component wipe out previous occurrences of the
# same component, but probably shouldn't.
local($profile) = defined $ENV{'MH'} ? $ENV{'MH'} :
$ENV{'HOME'} . "/.mh_profile";
local($profile_component) = 'x-bogus';
local($_);
&barf("can't open profile \"$profile\" - $!")
unless open(PROFILE, "<$profile");
while (<PROFILE>) {
/^(\S+):\s*/ && do {
($profile_component = $1) =~ tr/A-Z/a-z/;
$PROFILE_COMPONENT{$profile_component} = $';
};
/^[ \t]/ && do {
$PROFILE_COMPONENT{$profile_component} .= $_;
};
}
}
#
# Main program
#
($prog = $0) =~ s%.*/%%;
$editor = 'mhn'; # Default editor.
# Check the profile.
&read_profile;
if (defined $PROFILE_COMPONENT{$prog}) {
push(@Args, split(' ', $PROFILE_COMPONENT{$prog}));
}
# Check the command line arguments.
push(@Args, @ARGV);
while ($_ = shift @Args) {
/^-debug$/ && $debug++;
/^-editor$/ && ($editor = shift @Args);
/^-verbose$/ && $verbose++;
/^[^\-]/ && ($file = $_);
}
if (! $file) {
if (defined $ENV{'mhdraft'}) {
$file = $ENV{'mhdraft'};
}
else {
&barf("no draft file specified");
}
}
else {
$ENV{'mhdraft'} = $file;
}
&sh("$editor $file >/dev/null");
&sh("send $file >/dev/null");
print("\trm $file\n") if ($verbose || $debug);
unlink($file) unless $debug;
exit 0;